#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <boost/bind.hpp>

void print(int i)
{
	std::cout << i << std::endl;
}

class add : public std::binary_function<int,int,void>
{
public:
	void operator()(int i, int j) const {
		std::cout << "i = " << i << std::endl;
		std::cout << i + j << std::endl;
	}
};

void add_func(int i, int j)
{
	std::cout << "i = " << i << std::endl;
	std::cout << i + j << std::endl;
}

int main()
{
	std::vector<int> v;
	v.push_back(1);
	v.push_back(3);
	v.push_back(2);

	std::for_each(v.begin(), v.end(), print);

	std::for_each(v.begin(), v.end(), std::bind1st(add(), 10));
	std::for_each(v.begin(), v.end(), std::bind2nd(add(), 10));

	std::for_each(v.begin(), v.end(), boost::bind(add_func, 10, _1));
	std::for_each(v.begin(), v.end(), boost::bind(add_func, _1, 10));
}